<template>
    <div id="reviseArticleDetail">
        <el-button @click="goPrev" type="primary">返回</el-button>
        <box @submit="submit" :articleDetail="Article" style="margin-top:1rem"></box>
    </div>
</template>
<script>
    import box from '../components/infoDetail.vue';
    import {reviseArticle,checkArticleDetail} from 'api/webArticle'
    export default {
        components:{box},
        data(){
            return{
                Article:{}
            }
        },
        created(){
            this.getDetail();
        },
        methods:{
            getDetail(){
                // 查看文章详情
                checkArticleDetail(this.$route.query.uuid)
                    .then((response)=>{
                        let data=response.data;
                        this.Article={...data};
                    })
            },
            submit(obj){
                let params=obj;
                params.id=this.$route.query.id;
                params.uuid=this.$route.query.uuid;
                reviseArticle(this.$route.query.id,params)
                    .then((response)=>{
                        let data=response.data;
                        if(data.resultCode=='200'){
                            let tip='';
                            if(params.status=='DRAFT'){
                                tip='保存成功'
                            }else{
                                tip='发布成功'
                            }
                            this.$alert(tip, '提示', {
                                confirmButtonText: '确定',
                                callback: action => {
                                    this.$emit('updateList');
                                    this.$router.push({name:'webArticleList'});
                                }
                            })
                            
                        }
                        console.log(data);
                    })
            },
            goPrev(){
                this.$router.push({name:'webArticleList'})
            }
        }
    }
</script>
<style scoped lang="less">

</style>


